<template>
  <div>
    <div class="title">我的团队</div>

    <div class="rocketDiv">
      <div class="custom-progress">
        <div class="progress-bar" :style="{ width: progressWidth }"></div>
        <div class="progress-indicator" v-if="showIndicator" :style="{ left: progressWidth }">
          <img class="rocketImgS" src="../../../../static/engineering5188/prefecture/rocketImg.png" alt="indicator" />
          <!-- 替换为实际图标路径 -->
        </div>
        <div v-if="totalShow === true" :style="{ left: progressWidth }" class="progress-text">
          <span class="current-text">{{ currentText }}</span>
        </div>
      </div>
    </div>

    <div class="rocketText">
      <p class="textOne">邀请缴费累计{{totalText}}W</p>
      <p class="textTwo">返还会员费6W</p>
    </div>

    <div class="tableDiv">
      <div class="listDiv">
        <div class="list-Heard">
          <p class="pOne">序号</p>
          <p class="ptwo">被邀请人</p>
          <p class="pthree">日期</p>
          <p class="pfour">缴费金额</p>
          <p class="pfiv">返佣</p>
        </div>

        <div class="list-item" v-for="(item, index) in reputationData" :key="index">
          <div class="list-iitemOne">{{ index + 1 }}</div>
          <div class="itemName">
            {{ item.company_title }}
          </div>
          <div class="list-iitemthree">
            <div class="progressDiv">
              {{ item.created_at }}
            </div>
          </div>
          <div class="jine">{{ item.price }}</div>

          <div class="fanyong">{{ item.yongjin }}</div>
        </div>
      </div>

      <div class="pageClass">
        <div class="pageClass-first" @click="LoadFistData">首页</div>
        <div class="pageClass-Last" @click="LoadLastData">上一页</div>
        <template v-if="totalPage < 6">
          <div :class="{ 'pageClass-num': true, active: currentPage == 1 }" @click="loadPageData(1)"
            v-if="totalPage >= 1">
            1
          </div>
          <div :class="{ 'pageClass-num': true, active: currentPage == 2 }" @click="loadPageData(2)"
            v-if="totalPage >= 2">
            2
          </div>
          <div :class="{ 'pageClass-num': true, active: currentPage == 3 }" @click="loadPageData(3)"
            v-if="totalPage >= 3">
            3
          </div>
          <div :class="{ 'pageClass-num': true, active: currentPage == 4 }" @click="loadPageData(4)"
            v-if="totalPage >= 4">
            4
          </div>
          <div :class="{ 'pageClass-num': true, active: currentPage == 5 }" @click="loadPageData(5)"
            v-if="totalPage >= 5">
            5
          </div>
          <div :class="{ 'pageClass-num': true, active: currentPage == 6 }" @click="loadPageData(6)"
            v-if="totalPage >= 6">
            6
          </div>
        </template>
        <template v-else>
          <div :class="{ 'pageClass-num': true, active: currentPage == 1 }" @click="loadPageData(1)">
            1
          </div>
          <div :class="{ 'pageClass-num': true, active: currentPage == 2 }" @click="loadPageData(2)">
            2
          </div>
          <div :class="{ 'pageClass-num': true, active: currentPage == 3 }" @click="loadPageData(3)">
            3
          </div>
          <div :class="{ 'pageClass-num': true, active: currentPage == 4 }" @click="loadPageData(4)">
            4
          </div>
          <div :class="{ 'pageClass-num': true, active: currentPage == 5 }" @click="loadPageData(5)">
            5
          </div>
          <div :class="{ 'pageClass-num': true, active: currentPage == 6 }" @click="loadPageData(6)">
            6
          </div>

          <div class="pageShenLue">...</div>
          <!-- <div :class="{ 'pageClass-num': true, 'active': currentPage == totalPage - 1 }"
          @click="loadPageData(totalPage - 1)">{{ totalPage - 1 }}</div> -->
          <div :class="{ 'pageClass-num': true, active: currentPage == totalPage }" @click="loadPageData(totalPage)">
            {{ totalPage }}
          </div>
        </template>
        <div class="pageClass-Last" @click="LoadNextData">下一页</div>
        <div class="pageClass-first" @click="LoadEndData">末页</div>
      </div>
    </div>

    <div class="tishiDiv">
      <div class="youxi">游戏规则</div>

      <p class="pText">
        1、按照推荐缴费金额累计满30W，可以返还会员费6万，比如 一年的会员费是6W
        被邀请人（不限制人数）缴费累计达到30W时，返还会员费6W，超出30W的，按照一定的比例返给邀请人。
      </p>
      <p class="pText">
        2、按照推荐缴费金额累计满30W，可以返还会员费6万，比如 一年的会员费是6W
        被邀请人（不限制人数）缴费累计达到30W时，返还会员费6W，超出30W的，按照一定的比例返给邀请人。
      </p>
      <p class="pText">
        3、按照推荐缴费金额累计满30W，可以返还会员费6万，比如 一年的会员费是6W
        被邀请人（不限制人数）缴费累计达到30W时，返还会员费6W，超出30W的，按照一定的比例返给邀请人。
      </p>
      <p class="pText">
        4、按照推荐缴费金额累计满30W，可以返还会员费6万，比如 一年的会员费是6W
        被邀请人（不限制人数）缴费累计达到30W时，返还会员费6W，超出30W的，按照一定的比例返给邀请人。
      </p>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex';

export default {
  name: "Supplierteam",
  data() {
    return {
      totalPage: 20,
      currentPage: 1,

      pageSize: 10,
      total: 230, // 假设总数据量为230条，可根据实际情况修改
      pageRange: 5,
      // 控制显示的页码数量范围
      reputationData: [

      ],
      totalAll: 300000, // 目标值
      current: 0, // 当前值
      showIndicator: true,
      totalShow: true,
      setObj:{},
      fxSong: 60000,
    };
  },
  computed: {
    ...mapState([
      "userInfo",
    ]),
    progressWidth() {
      let a = (this.current / this.totalAll) * 100;
      console.log(a);

      if (a < 100) {
        this.totalShow = true;
        return (this.current / this.totalAll) * 100 + "%";
      } else {
        this.totalShow = false;
        return 100 + "%";
      }
    },
    currentText() {
      return `邀请缴费累计${this.current / 10000}万`;
    },
    totalText(){
      return `${+(this.totalAll) / 10000}`;
    },
    fixtext(){
      return `${+(this.fxSong) / 10000}`;
    }
  },
  created() {
    this.getProductList();
    this.getSetting();
  },
  methods: {
    getSetting(){
      this.$httpApi("/api/setting", {},'get').then(res=>{
        this.totalAll = +(res.data.fxMan);
        this.fxSong = +(res.data.fxSong);
      })
    },
    getProductList() {
      this.$httpApi("/api/myTeam", {
        token: this.userInfo.token,
        page: this.currentPage,
        pageSize: this.pageSize,
      }, 'get').then(res => {
        this.reputationData = res.data.list;
        this.totalPage = Math.ceil(res.data.count / this.pageSize);
        this.total = res.data.count;
        this.current = res.data.money;
      })
    },
    LoadEndData() {
      this.currentPage = this.totalPage;
      this.getProductList();
    },
    LoadNextData() {
      if (this.currentPage < this.totalPage) {
        this.currentPage++;
        this.getProductList();
      }
    },
    LoadFistData() {
      this.currentPage = 1;
      this.getProductList();
    },

    LoadLastData() {
      if (this.currentPage > 1) {
        this.currentPage--;
        this.getProductList();
      }
    },

    loadPageData(val) {
      this.currentPage = val;
      this.getProductList();
    },
  },
};
</script>

<style lang="less" scoped>
.pageClass {
  display: flex;
  margin-top: 26px;
  justify-content: center;
  padding-bottom: 26px;

  .pageClass-first {
    width: 40px;
    height: 32px;
    background: #ffffff;
    border-radius: 4px 4px 4px 4px;
    border: 1px solid #eeeeee;
    font-weight: normal;
    font-size: 14px;
    color: #7a7a7a;
    line-height: 32px;
    text-align: center;
    margin-right: 16px;
    cursor: pointer;
  }

  .pageClass-Last {
    width: 69px;
    height: 32px;
    background: #ffffff;
    border-radius: 4px 4px 4px 4px;
    border: 1px solid #eeeeee;
    font-weight: normal;
    font-size: 14px;
    color: #7a7a7a;
    line-height: 32px;
    text-align: center;
    margin-right: 10px;
    cursor: pointer;
  }

  .pageClass-num {
    width: 32px;
    height: 32px;
    background: #ffffff;
    border-radius: 4px 4px 4px 4px;
    border: 1px solid #eeeeee;
    font-weight: normal;
    font-size: 14px;
    color: #7a7a7a;
    line-height: 32px;
    text-align: center;
    margin-right: 10px;
    cursor: pointer;
  }

  .pageShenLue {
    font-weight: normal;
    font-size: 14px;
    color: #7a7a7a;
    margin-right: 10px;
  }

  .active {
    background: #014bc4;
    color: #fff;
  }
}

.pText {
  padding-right: 50px;
  font-family: PingFang SC, PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: #333333;
  line-height: 24px;
  text-align: left;
  font-style: normal;
  text-transform: none;
}

.youxi {
  font-family: Microsoft YaHei, Microsoft YaHei;
  font-weight: 400;
  font-size: 16px;
  color: #222222;
  text-align: left;
  font-style: normal;
  text-transform: none;
  margin-bottom: 15px;
}

.tishiDiv {
  width: 1150px;
  height: 273px;
  background: #fef7ea;
  border-radius: 8px 8px 8px 8px;
  border: 1px solid #eee0c8;
  margin: 31px auto;
  padding: 24px 40px;
}

.rocketImgS {
  width: 36px;
  height: 36px;
}

.fanyong {
  width: 100px;
  font-size: 14px;
  color: #333333;
  text-align: center;
}

.jine {
  width: 140px;
  text-align: center;
  margin-right: 110px;
  font-size: 14px;
  color: #333333;
}

.productCountNum {
  font-family: Arial, Arial;
  font-weight: 400;
  font-size: 12px;
  color: #999999;

  font-style: normal;
  text-transform: none;
}

.progressDiv {
  width: 260px;
  text-align: center;
  font-size: 14px;
  color: #333333;
}

.list-iitemthree {
  margin-right: 110px;
  font-size: 14px;
  color: #333333;
  text-align: center;
}

.itemName {
  width: 300px;
  text-align: center;
  font-family: PingFang SC, PingFang SC;
  font-weight: 400;
  font-size: 16px;
  color: #000000;
  margin-right: 50px;
  font-style: normal;
  text-transform: none;
  margin-left: 10px;
}

.list-iitemOne {
  width: 20px;
  line-height: 20px;
  text-align: center;
  font-family: PingFang SC, PingFang SC;
  font-weight: 400;
  font-size: 16px;
  color: #000000;
  font-style: normal;
  text-transform: none;
}

.list-item {
  width: 1150px;
  height: 63px;
  border-top: 1px solid #f0f0f0;
  line-height: 63px;
  display: flex;
  align-items: center;
  text-align: left;
  padding: 0 48px;
  margin: auto;
}

.pOne {
  padding-right: 120px;
  padding-left: 47px;
}

.pthree {
  padding-left: 280px;
  padding-right: 249px;
}

.pfour {
  padding-right: 177px;
}

.list-Heard {
  width: 1150px;
  height: 36px;
  background: #f8f9fa;
  border-radius: 0px 0px 0px 0px;
  line-height: 36px;
  display: flex;
  margin: auto;
  margin-top: 24px;
  font-family: PingFang SC, PingFang SC;
  font-weight: 500;
  font-size: 14px;
  color: #333333;
  font-style: normal;
  text-transform: none;
  text-align: right;
}

.textTwo {
  font-family: PingFang SC, PingFang SC;
  font-weight: bold;
  font-size: 18px;
  color: #000000;

  font-style: normal;
  text-transform: none;
}

.textOne {
  padding-right: 5px;
  font-family: PingFang SC, PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: #000000;

  font-style: normal;
  text-transform: none;
}

.rocketText {
  width: 700px;
  margin: auto;
  text-align: right;
  margin-top: 14px;
}

.rocketDiv {
  width: 600px;
  margin: auto;
  margin-top: 87px;
  height: 15px;
  background: #ededed;
  border-radius: 6px 6px 6px 6px;
}

.custom-progress {
  position: relative;
  height: 10px;
  margin: 20px 0;
}

.progress-bar {
  height: 15px;
  background-color: orange;
  transition: width 0.3s ease;
  border-radius: 6px 6px 6px 6px;
}

.progress-indicator {
  position: absolute;
  top: -15px;
  width: 20px;
  height: 20px;
  margin-left: -10px;
}

.current-text {
  margin-left: -36px;
  font-family: PingFang SC, PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: #000000;
  line-height: 32px;
  text-align: center;
  font-style: normal;
  text-transform: none;
}

.progress-text {
  position: relative;
  margin-top: 10px;
  font-size: 14px;
}

.title {
  height: 56px;
  background: #ffffff;
  line-height: 56px;
  border-radius: 0px 0px 0px 0px;
  font-family: Microsoft YaHei, Microsoft YaHei;
  font-weight: bold;
  font-size: 16px;
  color: #333333;
  font-style: normal;
  text-transform: none;
  border-bottom: 4px solid #f5f5f5;
  padding-left: 32px;
}
</style>